package routers

import (
	"beego_background_framework/controllers"
	"github.com/astaxie/beego"
)

func init() {

	//图片上传
	beego.Router("/upload", &controllers.CommonController{}, "Post:Upload")

	ns := beego.NewNamespace("/admin",
		// 后台页面
		beego.NSRouter("/", &controllers.IndexController{}, "*:Index"),
		beego.NSRouter("/login", &controllers.IndexController{}, "*:Login"),
		beego.NSRouter("/dologin", &controllers.IndexController{}, "Post:DoLogin"),
		beego.NSRouter("/welcome", &controllers.IndexController{}, "*:Welcome"),
		beego.NSRouter("/person", &controllers.IndexController{}, "*:Person"),
		beego.NSRouter("/logout", &controllers.IndexController{}, "*:Logout"),
		// 管理员列表
		beego.NSNamespace("/sys",
			beego.NSRouter("/", &controllers.AdminSysController{}, "*:Index"),
			beego.NSRouter("/update_status", &controllers.AdminSysController{}, "*:UpdateStatus"),
			beego.NSRouter("/create", &controllers.AdminSysController{}, "*:Create"),
			beego.NSRouter("/add", &controllers.AdminSysController{}, "*:Add"),
			beego.NSRouter("/edit/:id", &controllers.AdminSysController{}, "*:Edit"),
			beego.NSRouter("/update/:id", &controllers.AdminSysController{}, "*:Update"),
			beego.NSRouter("/destroy/:id", &controllers.AdminSysController{}, "*:Destroy"),
		),
		//角色组
		beego.NSNamespace("/group",
			beego.NSRouter("/", &controllers.AdminGroupController{}, "*:Index"),
			beego.NSRouter("/create", &controllers.AdminGroupController{}, "*:Create"),
			beego.NSRouter("/add", &controllers.AdminGroupController{}, "*:Add"),
			beego.NSRouter("/edit/:id", &controllers.AdminGroupController{}, "*:Edit"),
			beego.NSRouter("/update/:id", &controllers.AdminGroupController{}, "*:Update"),
			beego.NSRouter("/destroy/:id", &controllers.AdminGroupController{}, "*:Destroy"),
		),
		//管理员日志
		beego.NSNamespace("/log",
			beego.NSRouter("/", &controllers.AdminLogController{}, "*:Index"),
		),
		//权限管理
		beego.NSNamespace("/rule",
			beego.NSRouter("/", &controllers.AdminRuleController{}, "*:Index"),
			beego.NSRouter("/update_status", &controllers.AdminRuleController{}, "*:UpdateStatus"),
			beego.NSRouter("/create", &controllers.AdminRuleController{}, "*:Create"),
			beego.NSRouter("/add", &controllers.AdminRuleController{}, "*:Add"),
			beego.NSRouter("/edit/:id", &controllers.AdminRuleController{}, "*:Edit"),
			beego.NSRouter("/update/:id", &controllers.AdminRuleController{}, "*:Update"),
			beego.NSRouter("/destroy/:id", &controllers.AdminRuleController{}, "*:Destroy"),
			beego.NSRouter("/icon", &controllers.AdminRuleController{}, "*:Icon"),
		),
		//单位管理
		beego.NSNamespace("/department",
			beego.NSRouter("/", &controllers.DepartmentController{}, "*:Index"),
			beego.NSRouter("/create", &controllers.DepartmentController{}, "Get:Create"),
			beego.NSRouter("/add", &controllers.DepartmentController{}, "Post:Store"),
			beego.NSRouter("/edit/:id", &controllers.DepartmentController{}, "Get:Edit"),
			beego.NSRouter("/update/:id", &controllers.DepartmentController{}, "Post:Update"),
			beego.NSRouter("/destroy/:id", &controllers.DepartmentController{}, "Get:Destroy"),
		),
		//意见沟通
		beego.NSNamespace("/communication",
			beego.NSRouter("/real_time", &controllers.ChatController{}, "*:Index"),
			beego.NSRouter("/websocket", &controllers.ChatController{}, "*:Socket"),
		),
	)
	beego.AddNamespace(ns)
}
